#pragma once

class IDataSample : public IAutoObject
{
public:
	IDataSample(){}
	virtual ~IDataSample(){}

public:
	virtual PBYTE	GetData()=0;
	virtual size_t	GetDataLen()=0;
	virtual BOOL	Write(PBYTE data,long length)=0;
};


class TDataSample	: public IDataSample
{
public:
	TDataSample()
	:m_pbData(NULL),
	m_length(0)
	{
	}
	virtual ~TDataSample()
	{
		SAFE_DELETE(m_pbData);
		m_length = 0;
	}

public:
	virtual PBYTE GetData()
	{
		return m_pbData;
	}
	virtual size_t GetDataLen()
	{
		return m_length;
	}
	virtual BOOL Write(PBYTE data,long length)
	{
		if(!data || length <= 0)
			return FALSE;
		
		SAFE_DELETE(m_pbData);
		m_pbData = new BYTE[length];
		if(!m_pbData)
			return FALSE;

		CopyMemory(m_pbData, data, length);
		m_length = length;
		return TRUE;
	}
private:
	PBYTE	m_pbData;
	long	m_length;
};


